package com.promis.party.ui.partywork.dailywork.tracking;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.promis.compat.StatusBarCompat;
import com.promis.party.R;
import com.promis.party.helper.ContextHelper;
import com.promis.party.helper.UIHepler;
import com.promis.util.DrawableUtils;

/**
 * Created by zcy on 2018/9/25.
 */

public class TrackingSuperviseResultActivity extends AppCompatActivity {

    private ContextHelper contextHelper;
    private EditText etxtvContent;
    private TextView txtvCount;
    private TextView txtvSubmit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        StatusBarCompat.translucentStatusBar(this);
        StatusBarCompat.blackTextStatusBar(this);
        setContentView(R.layout.activity_tracking_result);
        UIHepler.goBack(TrackingSuperviseResultActivity.this, R.id.activity_tracking_result_txtv_head);

        etxtvContent = findViewById(R.id.activity_tracking_result_txtv_content);
        txtvCount = findViewById(R.id.activity_tracking_result_txtv_count);
        txtvSubmit = findViewById(R.id.activity_tracking_result_txtv_submit);

        initData();
        initListener();
    }

    private void initData() {
        contextHelper = new ContextHelper(getBaseContext());
    }

    private void initListener() {
        etxtvContent.addTextChangedListener(mTextWatcher);

        txtvSubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    private TextWatcher mTextWatcher = new TextWatcher() {
        private CharSequence temp;

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            temp = s;
            txtvCount.setText((start + count) + "/100");
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (temp.length() > 100) {
                Toast.makeText(TrackingSuperviseResultActivity.this, "你输入的字数已经超过了限制！", Toast.LENGTH_SHORT).show();
            }
        }
    };
}